package com.ruoyi.project.datacollection.datasource.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.datacollection.datasource.domain.Datasource;
import com.ruoyi.project.datacollection.datasource.domain.PageRes;
import com.ruoyi.project.datacollection.datasource.mapper.DatasourceMapper;
import com.ruoyi.project.datacollection.datasource.service.DatasourceService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author lenovo
 * @description 针对表【qrtz_datasource(数据源管理模块)】的数据库操作Service实现
 * @createDate 2022-07-28 10:49:12
 */
@Service
public class DatasourceServiceImpl implements DatasourceService {

    @Resource
    private DatasourceMapper datasourceMapper;


    @Override
    public AjaxResult insertData(Datasource datasource) {
        int i = datasourceMapper.insertAll(datasource);
        if (i > 0) {
            return AjaxResult.success("操作成功");
        }
        return AjaxResult.error(600, "插入失败");
    }

    @Override
    public AjaxResult selectDataById(Integer id) {
        Datasource datasource = datasourceMapper.selectOneBySourceId(id);
        return AjaxResult.success("操作成功", datasource);
    }

    @Override
    public AjaxResult deleteBySourceId(Integer id) {
        int i = datasourceMapper.deleteBySourceId(id);
        if (i > 0) {
            return AjaxResult.success("删除成功");
        }
        return AjaxResult.error("删除失败");
    }
}




